<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="top">

        </ui:define>

        <ui:define name="left">

        </ui:define>
        <ui:define name="content">

            <h:form prependId="false" id="form"  >    


                <p:dataGrid var="vendor" value="#{vendorEntityController.vendors}" columns="3"  
                            rows="12" paginator="true" effect="true"  
                            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                            rowsPerPageTemplate="9,12,15">  

                    <p:column>  
                        <p:panel header="#{vendor.companyName}" style="text-align: center">  

                            <div style="text-align: center; width: 100%;">
                                <p:graphicImage value="/images/supplier/#{vendor.companyName}.jpg" />
                            </div>


                            <h:panelGrid columns="3" style="width:100%">  


                                <p:lightBox width="40%" height="60%" >  
                                    <p:commandLink value="Info" update="t" >

                                        <f:setPropertyActionListener value="#{vendor}"   
                                                                     target="#{vendorEntityController.selectedVendor}" /> 
                                    </p:commandLink >

                                    <f:facet name="inline">  
                                        <h:panelGrid columns="1" style ="width:100%">  

                                            <p:outputPanel id="t" style="color:#FFFFFF; text-align: center" >



                                                <h:outputLabel for="name" value="Representatives name :" style ="text-align: center;" />  
                                                <h:outputText id="name" value="#{vendorEntityController.selectedVendor.name}" /> 
                                                <br/>
                                                <br/>
                                                <h:outputLabel for="name1" value="Contact number:" style ="text-align: center;" />
                                                <h:outputText id="name1" value="#{vendorEntityController.selectedVendor.contact.contactNumber}" /> 
                                                <br/>
                                                <br/>

                                                <h:outputLabel for="name2" value="Rating point:" style ="text-align: center;" />  
                                                <h:outputText id="name2" value="#{vendorEntityController.selectedVendor.star}" /> 
                                                <h:outputText id="name4" value="/5.0" /> 
                                                <br/>
                                                <br/>
                                                <h:outputLabel for="name" value="Address:" />
                                                <br/>
                                                <br/>
                                                <p:dataList  id="addresslist" value="#{vendorEntityController.selectedVendor.contact.addresses}"  
                                                             var="address" widgetVar="addresstable" >


                                                    <p:column >  

                                                        <h:outputText value="#{address.type}" />
                                                        <br />

                                                        <h:outputText value="#{address.streetAddress}"  />
                                                        <br />

                                                        <h:outputText value="#{address.city}"  />                
                                                        <h:outputText value=", " />
                                                        <h:outputText value="#{address.stateOrProvice}" />
                                                        <br />

                                                        <h:outputText value="#{address.country}"  />
                                                        <h:outputText value=", " />
                                                        <h:outputText value="#{address.zipCode}"  />
                                                        <br />

                                                    </p:column>
                                                </p:dataList> 
                                                <br/>
                                                <br/>
                                                <h:outputLabel for="name" value="Raws Material provided:" style ="text-align: right"/>
                                                <p:dataList value="#{vendorEntityController.selectedVendor.rms}" var="raw" type="ordered"> 

                                                    #{raw.productName}

                                                </p:dataList> 



                                            </p:outputPanel>  
                                        </h:panelGrid>  
                                    </f:facet>  
                                </p:lightBox>   


                                <p:commandLink value="Edit" action="#{vendorEntityController.prepareEdit}" >
                                    <f:setPropertyActionListener value="#{vendor}"   
                                                                 target="#{vendorEntityController.selectedVendor}" /> 
                                </p:commandLink>
                                <p:commandLink value="Delete" action="#{vendorEntityController.deleteSupplier}">
                                    <f:setPropertyActionListener value="#{vendor}"   
                                                                 target="#{vendorEntityController.selectedVendor}" /> 
                                </p:commandLink>


                            </h:panelGrid>  
                        </p:panel>  
                    </p:column>  


                </p:dataGrid>  

                <br/>
                <p:separator/>     <br/>
                <h:commandLink value="Generate Supplier Product Report(Refresh the page after to download the most up to date report)" action="#{jasper.generateSupplierReport}" target="_blank" /> 

                <br/>
           
  <h:commandLink  title="Download" rendered ="#{jasper.exist}" >  
                    <p:graphicImage value="/images/download.gif" />  
                    <p:fileDownload value="#{download.file}"/>  
                </h:commandLink> 
            </h:form>  




        </ui:define>



    </ui:composition>



</html>